{extend name="public/base" /}

{block name="title"}<title>我提交的奖扣</title>{/block}

{block name="pjax_container"}
<style>
    .col-sm-2 {
        width: 23.666667%;
        height: 33px;
        line-height: 40px;
        padding-top: 15px;
    }

    .col-sm-7 {
        padding-top: 15px;
    }
    .layui-layer-content{
        padding: 15px;
    }
    tr>th,
    td {
        text-align: center;
    }

    .btn-group-xs>.btn,
    .btn-xs {
        padding: 5px;

    }

    .modal-content {
        margin-top: 150px;
        /*width: 600px;*/
        /*height: 690px;*/

    }

    .modal-body {
        padding: 27px;
        /*width: 856px;*/
        /*height: 570px;*/
        display: flex;
    }

    .modal-right {
        flex: 1;
        border: 1px solid #eee;
        margin-left: 30px;
    }

    .modal-left {
        height: 100%;
    }

    .modal-right>h4 {
        width: 100%;
        display: flex;
        justify-content: space-around;
    }

    .form-control {
        border-radius: 6px;
    }

    .table-body {
        width: 540px;
        height: 462px;
        border-radius: 6px;
        background-color: #eee;
    }

    .table-left {
        margin-right: 2%;
        width: 49%;
        height: 100%;
        float: left;
        border: 1px solid #eee;
        background-color: #fff;
    }

    .table-right,
    .table-right2 {
        width: 49%;
        height: 100%;
        border: 1px solid #eee;
        float: left;
        padding-top: 10px;
        background-color: #fff;
    }

    .content-header>.breadcrumb>li {
        color: #999;
    }

    .content-header>.breadcrumb>.active {
        color: #666;
    }

    .content-header {
        height: 51px;

    }

    .btn-primary {
        background-color: #1890FF;
        color: #fff;
        border: none;
        border-radius: 6px !important;
        padding: 8px 10px;
        height: 34px;
    }

    .box-primary {
        border-top-color: #ecf0f5 !important;
        border-top-width: 16px;

    }

    .btn-primary:hover {
        background-color: #1890FF;
        color: #fff;
        border: none;
        opacity: .9;
        border-radius: 6px !important;
    }

    .btn-success {
        border-radius: 6px;
        border: none;
        outline: none;
        margin: 5px;
        padding: 8px 10px;
    }

    .delete-one {
        background-color: ff4141 !important;
        margin-left: 15px;
        border-radius: 6px;
    }

    .sreachs {
        background-color: #1890FF;
        color: #fff;
        border: none;
        border-radius: 6px !important;
        margin-left: 15px;
        padding: 7px 15px;
        height:34px;
    }

    .form-control {
        width: 90%;
        border-radius: 8px;
    }
    .btn-danger {
        border: none;
        outline: none;
        padding: 8px 10px;
        height: 34px;
    }

    .timepicker {
        margin: 10px 5px !important;
    }

    .pagination .active {
        background-color: #1890FF;
    }

    .form-horizontal>a {
        margin: 5px;
    }
    .input-group-sm>label{
        margin-left: 10px;
        }
    .plsc,.plch{background-color: #dd4b39}
</style>

<section class="content-header">
    <ol class="breadcrumb">
        <li>积分管理</li>
        <li class="active">我提交的奖扣</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <a href="/company/integral/index_edit" class="btn btn-sm btn-primary"><i class="fa fa-save"></i> 新增(不包含专审事件)</a>
                <a href="/company/integral/index_check_edit" class="btn btn-sm btn-primary"><i class="fa fa-save"></i> 新增(专审事件)</a>
                <a href="/company/integral/index_take" class="btn btn-sm btn-primary"><i class="fa fa-save"></i> 我参与的奖扣</a>
                <div class="" style="top:10px;    margin: 10px;">
                    <form action="{:search_url(['page','status','name','first_check_user_id','last_check_user_id','s_time','e_time','s_time_record','e_time_record'])}" method="GET" pjax-search="" id="export_form">
                        <div class="input-group input-group-sm">
                                <input type="hidden" name="page" value="1" />
                                <label>事件主题<input type="text" style="display: inline-block;width: 327px;margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height: 34px;border-radius: 3px;" name="name" value="{:input('get.name','')}" placeholder="{$placeHolderSearch|default='事件主题'}" /></label>

                                <label>初　审人</label>
                                <div class="xyqk_input">
                                    <input type="text" style="display: inline-block;width: 327px;margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height: 34px;border-radius: 3px;"  name="first_check_user_name" class="first_check_user_name" value="{:input('get.first_check_user_name','')}" placeholder="" autocomplete="off" />
                                    <input type="hidden" name="first_check_user_id" class="first_check_user_id" value="{:input('get.first_check_user_id','')}" >
                                    <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                                </div>
                                <label>终　审人 </label>
                                <div class="xyqk_input">
                                    <input type="text" style="display: inline-block;width: 327px;margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height: 34px;border-radius: 3px;"  name="last_check_user_name" class="last_check_user_name" value="{:input('get.last_check_user_name','')}" placeholder="" autocomplete="off" />
                                    <input type="hidden" name="last_check_user_id" class="last_check_user_id" value="{:input('get.last_check_user_id','')}" >
                                    <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                                </div>

                                <div class="xyqk_input">
                                    
                                    <div class="delect_btn_an" style="right: 15px; top: 6px;"><i class="fa fa-remove"></i></div>
                                </div>
                                
                                <label style="margin-bottom:0;">奖扣时间<input class="timepicker" name="s_time" value="{:input('get.s_time')}" placeholder="开始时间"
                                    style="margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height: 34px;border-radius: 3px;width:140px;"
                                    AUTOCOMPLETE="off">　--　<input class="timepicker" name="e_time" value="{:input('get.e_time')}" placeholder="结束时间"
                                    style="margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height:34px;border-radius: 3px;width:140px;" AUTOCOMPLETE="off"></label>                                  
                                <label style="margin-bottom:0;">记录时间<input class="timepicker" name="s_time_record" value="{:input('get.s_time_record')}" placeholder="开始时间"
                                    style="margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height: 34px;border-radius: 3px;width:140px;"
                                    AUTOCOMPLETE="off">　--　<input class="timepicker" name="e_time_record" value="{:input('get.e_time_record')}" placeholder="结束时间"
                                    style="margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height: 34px;border-radius: 3px;width:140px;"
                                    AUTOCOMPLETE="off"></label>
                                <script type="text/javascript">
                                    $(function(){
                                        var now = new Date();
                                        var currentYear=now.getFullYear();
                                        var startDate = new Date(currentYear,0,1);
                                        var endDate = new Date(currentYear+1,0,1);
                                        $('.timepicker').datetimepicker({
                                            format: "{$timepickerFormat | default='YYYY-MM-DD'}",   //YYYY-MM-DD HH:mm:ss
                                            locale: moment.locale('zh-cn'),
                                            // minDate:startDate,
                                            maxDate : endDate
                                        });
                                    })
                                </script>
                                <label>状　　态
                                    <select class="select2" name="status" style="width: 327px;display: inline-block;margin: 0px 5px;padding-left: 3px;border: 1px solid #ccc;height: 34px;border-radius: 3px;">
                                        <option value="-1" {if condition="input('get.status',-1)== -1" }selected="selected" {/if}>全部 </option>
                                        <option value="0" {if condition="input('get.status',-1)== 0" }selected="selected" {/if}>待初审 </option>
                                        <option value="1" {if condition="input('get.status',-1)== 1" }selected="selected" {/if}>待终审 </option> 
                                        <option value="2" {if condition="input('get.status',-1)== 2" }selected="selected" {/if}>审核通过 </option>
                                        <option value="4" {if condition="input('get.status',-1)== 4" }selected="selected" {/if}>拟稿 </option>
                                    </select>
                                </label>
                                <div class="input-group-btn" style="display: inline-block;height:34px;">
                                    <button type="submit" class="btn btn-default sreachs" style="height:34px;">
                                        <i class="fa fa-search"></i> 查询
                                    </button>
                                </div>
                            
                        </div>
                    </form>
                </div>
                <div class="box-header with-border">
                    <div class="pull-left">
                        {:authAction(CONTROLLER_NAME.'/review_import','review_import')}
                        <a href="__STATIC__/review_import_template.xlsx" class="btn btn-sm btn-primary"><i class="fa fa-download"></i> 下载导入模板</a>
                    </div>
                    <div style="float: right;margin-right: 80px;">
                        <a class="btn btn-primary plsh" href="javascript:void(0);" data-url="/company/integral/audit_sub" data-title="确认提交?"> 批量提交</a>
                        <a class="btn btn-primary plsc" href="javascript:void(0);" data-url="/company/integral/audit_del" data-title="确认删除?"> 批量删除</a>
                        <a class="btn btn-primary plch" href="javascript:void(0);" data-url="/company/integral/audit_withdraw_list" data-title="确认撤回?"> 批量撤回</a>
                    </div>
                </div>
                <div class="box-body table-responsive">
                    <table class="table table-bordered table-hover">
                        <tr>
                            <th width="35"><input type="checkbox" class="minimal checkbox-toggle"></th>
                            <th>奖扣时间</th>
                            <th>记录时间</th>
                            <th>主题</th>
                            <th>A分</th>
                            <th>B分</th>
                            <th>人次</th>
                            <th>记录人</th>
                            <th>初审人</th>
                            <th>终审人</th>
                            <th>审核状态</th>
                            <th>操作</th>
                        </tr>
                        {volist name="$list" id="v"}
                        <tr>
                            <td><input type="checkbox" name="id[]" value="{$v.id}" data-status="{$v.status}" data-fuser="{$v.first_check_user_id}" data-luser="{$v.last_check_user_id}" data-ruser="{$v.record_user_id}" class="minimal checkbox"></td>
                            <td>{:date('Y-m-d',$v["prize_buckle_time"])}</td>
                            <td>{:date('Y-m-d H:i',$v["create_time"])}</td>
                            <td>
                                {if condition="$v['check_status'] == 2"}
                                    <span style="color:red; font-size:11px; border-radius: 50%;border:1px solid red;width: 17px; height: 16px; display: inline-block;">驳</span>
                                {/if}
                                <a href="{:url('integral/event_info',['id'=>$v.id])}">{$v["theme"]}</a>
                            </td>
                            <td>{$v["integral_a_add"]}/{$v["integral_a_del"]}</td>
                            <td>{$v["integral_b_add"]}/{$v["integral_b_del"]}</td>
                            <td>{$v["people_sum"]}</td>
                            <td>{$users[$v.record_user_id]}</td>
                            <td>{$users[$v.first_check_user_id]??''}</td>
                            <td>{$users[$v.last_check_user_id]??''}</td>
                            <td>
                                {if condition="$v.status eq 0"}
                                待初审
                                {elseif condition="$v.status eq 1"}
                                待终审
                                {elseif condition="$v.status eq 2"}
                                审核通过
                                {elseif condition="$v.status eq 3"}
                                作废
                                {elseif condition="$v.status eq 4"}
                                拟稿
                                {/if}
                            <td>
                                <form class="form-horizontal" style="display: inline-block" method="POST"
                                    action="{:url('audit_sub')}" onsubmit="return false" data-status="{$v.status}" data-fuser="{$v.first_check_user_id}" data-luser="{$v.last_check_user_id}" data-ruser="{$v.record_user_id}">
                                    <input type="hidden" name="id" value='{$v["id"]}' />
                                    <input name="check_opinion" class="check_opinion" value="" type="hidden">
                                    <!--撤回-->
                                    {if condition="$v.status==0 && $v.record_user_id==$user_id"}
                                    <button type="submit" class="btn btn-sm btn-danger ch_sub_submit ch"><i class='fa fa-reply'></i> 撤回</button>
                                    {/if}

                                    {if condition="$v.status==1 && $v.first_check_user_id==$user_id"}
                                    <button type="submit" class="btn btn-sm btn-danger ch_sub_submit ch"><i class='fa fa-reply'></i> 撤回</button>
                                    {/if}

                                    {if condition="$v.status==2 && $v.last_check_user_id==$user_id"}
                                    <button type="submit" class="btn btn-sm btn-danger ch_sub_submit ch"><i class='fa fa-reply'></i> 撤回</button>
                                    {/if}
                                    <!--audit_withdraw-->
                                    <!--<button type="submit" id="ch" class="btn btn-sm btn-danger submits"><i class='fa fa-reply'></i>撤回</button>-->
                                    {if condition="$v.status == 4 && $v.record_user_id == $user_id"}
                                    <a class='btn btn-primary' href="{:url('audit_edit', ['id'=>$v['id']])}"><i class='fa fa-edit'></i> 编辑</a>
                                    <button type="submit" class="btn btn-sm btn-primary audit_sub_submit tg"
                                        value="{$v.first_check_user_id}" data="{$user_id}"><i class="fa fa-save"></i>
                                        提交</button>
                                    <a class='btn btn-sm btn-danger audit-del' href='javascript:void(0);' data-url="{:url('audit_del')}" data-id="{$v['id']}"><i class='fa fa-trash'></i> 删除</a>
                                    {/if}
                                    <button class="submits hidden"></button>
                                </form>
                                <!--记录人：催审-->
                                {if condition="in_array($v.status,[0,1]) && $v.record_user_id == $user_id"}
                                <a class='btn btn-sm btn-success audit-urge' href='javascript:void(0);' data-url="{:url('audit_urge')}" data-id="{$v['id']}"><i class='fa fa-volume-up'></i> 催审</a>
                                {/if}
                            </td>
                        </tr>
                        {/volist}
                    </table>
                </div>
                <div class="box-footer clearfix" style="display: flex;justify-content: flex-end;">
                    {$list->render()}
                </div>
            </div>
        </div>
    </div>
</section>
<script type="text/javascript" src="__STATIC__/system/iCheck/icheck.min.js"></script>
<script>
    $(function () {
        // 列表部分 全选
        $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
            checkboxClass: 'icheckbox_minimal-blue',
            radioClass: 'iradio_minimal-blue'
        });
        $('.checkbox-toggle').on('ifChecked', function (event) {
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("check");
        });
        $('.checkbox-toggle').on('ifUnchecked', function (event) {
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("uncheck");
        });
    });
    $('.ch').on('click', function () {
        $(this).parents(".form-horizontal").attr('action', "{:url('audit_withdraw')}");
    })
    $('.tg').on('click', function () {
        $(this).parents(".form-horizontal").attr('action', "{:url('audit_sub')}");
    })
    $('.index_recall').on('click', function () {
        var id = $(this).attr('data-id');
        var res = confirm('确定撤回么?')
        if (res === true) {
            $.ajax({
                url: '{:url("integral/index_del")}',
                type: 'get',
                dataType: 'json',
                data: { 'id': id },
                success: function (data) {
                    $.amaran({ 'message': data.msg });
                    if (data.err == 0) {
                        window.location.reload()
                    }
                }
            });
        }
    });
</script>

<script>
    //批量提交
    $('.plsh,.plsc').on('click', function(){
        var $tmpStatus = [];
        var type = 0;
        $(".checkbox:checked").each(function(){
            //判断状态
            if($tmpStatus.length < 1){
                $tmpStatus.push($(this).data('status'));
                if($(this).data('status') != 4){
                    layui.layer.msg('拟稿状态才可以操作');
                    type = 1;
                }
            }else if($.inArray($(this).data('status'),$tmpStatus) < 0){
                layui.layer.msg('不同状态，不能批量操作');
                type = 1;
            }
        });
        if($tmpStatus.length == 0){
            layui.layer.msg('请选择');
            return false;
        }
        //判断人
        $(".checkbox:checked").each(function(){
            if($(this).data('ruser') != {$user_id}) {
                layui.layer.msg('批量操作，必须是同一记录人');
                type = 1;
            }
        });
        if(type == 1){
            return false;
        }
        ajax_submit_all(this);
    });



    //批量撤回
    $('.plch').on('click', function(){
        var $tmpStatus = [];
        var $status = '';
        var type = 0;
        $(".checkbox:checked").each(function(){
            //判断状态
            if($tmpStatus.length < 1){
                $tmpStatus.push($(this).data('status'));
            }else if($.inArray($(this).data('status'),$tmpStatus) < 0){
                layui.layer.msg('不同状态，不能批量操作');
                type = 1;
            }
            $status = $(this).data('status');
        });
        if($tmpStatus.length == 0){
            layui.layer.msg('请选择');
            return false;
        }
        $(".checkbox:checked").each(function(){
            if(($status == 1 && $(this).data('fuser') == "{$user_id}")||($status == 0 && $(this).data('ruser') == "{$user_id}")){

            }else{
                layui.layer.msg('批量撤回，状态和人要对应');
                type = 1;
            }
        });
        if(type == 1){
            return false;
        }
        ajax_submit_all(this);

    });
    //
    // //批量删除
    // $('.plsc').on('click', function(){
    //     $(".checkbox:checked").each(function(){
    //         //判断状态
    //         if($(this).data('status') != 4) {
    //             layui.layer.msg('不同状态，不能批量操作');
    //             return false;
    //         }
    //     });
    //
    //     //判断人
    //     $(".checkbox:checked").each(function(){
    //         if($(this).data('ruser') != "{$user_id}"){
    //             layui.layer.msg('批量删除，必须是同一记录人');
    //             return false;
    //         }
    //     });
    //     ajax_submit_all(this);
    // });

</script>


<!-- Modal 弹出层重写 单选  -->
<link rel="stylesheet" href="__STATIC__/global/an_tree_css/an_tree_css.css">
<div class="modal fade" id="myModal_single" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">人员选择</h4>
            </div>
            <div class="modal-body">
                <div class="modal-left">
                    <div class="modal-left-title" style="margin-bottom: 20px;">
                        <div class="input-group">
                            <input name="search_user_name" type="text" class="form-control" placeholder="">
                            <span class="input-group-btn">
                                <button class="btn btn-info search_btn" type="button"
                                    style="width: 47px; height: 34px; background-color: #1890FF;border: none;outline: none;">
                                    <span class="glyphicon glyphicon-search"></span>
                                </button>
                            </span>
                        </div>
                    </div>
                    <div class="input-group table-body">
                        <div class="table-left">
                            <div class="an_tree">

                            </div>
                        </div>
                        <div class="table-right">
                            <div class="an_tree_list">
                                <div class="an_list_title">

                                </div>
                                <div class="an_list_con">
                                    <!-- <div class="an_list_item">
                                        <div class="item_info">
                                            <span class="name">aaa</span>/
                                            <span>88</span>/
                                            <span>部门</span>
                                        </div>
                                        <div class="item_box item_box_check"><i class="fa fa-check"></i></div>
                                    </div> -->
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary popups_submit">确认</button>
            </div>
        </div>
    </div>

</div>
<!-- 单选弹窗操作  -->
<script>
    var double_max;//扣分上限
    var first_id="";//初审人id
    var last_id="";//终审人id
    var principal_user_id="";//任务负责人id
    var now_item_name;//名字输入框
    var now_item_id;//id输入框
    var user_type;
    //确认按钮
    $('#myModal_single .popups_submit').click(function (e) {
        $('#myModal_single').modal('hide');
        var checked = $(".an_tree_list").find(".list_item_check");
        now_item_name.val(checked.attr("user_name"));
        now_item_id.val(checked.attr("user_id"));
        now_item_name.attr("limits_b",checked.attr("limits_b"))
    });
    //当弹窗关闭时执行重置弹窗
    $('#myModal_single').on('hidden.bs.modal', function () {
        // 执行一些动作...重置弹窗
        $(".an_tree_list .an_list_title").html("");
        $(".an_tree_list .an_list_con").html("");
        $(".tree_txt_active").removeClass("tree_txt_active");
        $(".an_tree_pack").hide();
        $(".an_tree .fa").removeClass("fa-caret-down").addClass("fa-caret-right");
        $("#myModal_single input[name='search_user_name']").val("");
    });
    // 任务负责人
    $("input[name='principal_user_name']").focus(function () {
        $('#myModal_single').modal('show');
        double_max = 0;
        now_item_name = $(this);
        now_item_id = $("input[name='principal_user_id']");//节点
        user_type = 0;
    });
    // 初审人
    $("input[name='first_check_user_name']").focus(function () {
        $('#myModal_single').modal('show');
        double_max = $("input[name='double_max']").val();
        now_item_name = $(this);//节点
        now_item_id = $("input[name='first_check_user_id']");//节点
        last_id = $("input[name='last_check_user_id']").val();//id值
        user_type = 1;
    });
    // 终审人
    $("input[name='last_check_user_name']").focus(function () {
        $('#myModal_single').modal('show');
        double_max = $("input[name='double_max']").val();
        now_item_name = $(this);//节点
        now_item_id = $("input[name='last_check_user_id']");//节点
        first_id = $("input[name='first_check_user_id']").val();//id值
        user_type = 2;
    });
</script>
<!-- 树结构js操作 单选  -->
<script>
    $("#myModal_single .an_tree").on("click", ".fa", function () {
        $(this).toggleClass("fa-caret-down");
        $(this).toggleClass("fa-caret-right");
        $(this).parents(".an_tree_set").eq(0).children(".an_tree_pack").toggle();
    });
    $("#myModal_single").on("click", ".an_tree_txt,.search_btn", function () {
        $(".an_tree").find(".tree_txt_active").removeClass("tree_txt_active");
        $(this).addClass("tree_txt_active");
        var department_id = $(this).attr("data_id");
        var department_name = $(this).html();
        var user_name = $("#myModal_single input[name='search_user_name']").val();
        // console.log(user_name);
        $.ajax({
            type: 'get',
            url: "{:url('base/base_department_per')}",
            data: {'department_id' : department_id,'user_name' : user_name},
            dataType:"json",
            success: function (data) {
                // var json = JSON.parse(data);
                // console.log(data);
                var content = '';
                $.each(data, function (index, value) {
                    if(value.limits==undefined){
                         var limits=0;
                    }else{
                        var limits=value.limits.b;
                    }
                    content += '<div class="an_list_item" user_name="'+value.name+'" user_id="'+value.id+'" limits_b="'+limits+'"><div class="item_info"><span class="name">' + value.name + '</span>/<span>' + value.job_number + '</span>/<span>' + value.department_name + '</span></div><div class="item_box "><i class="fa fa-check"></i></div></div>'
                });
                $('.an_list_con').html("");
                $('.an_list_con').append(content);
                $('.an_list_title').html(department_name + data.length + '人');
            }
        })
    });
    $("#myModal_single .an_tree_list").on("click", ".an_list_item", function () {
        $(this).siblings().removeClass("list_item_check");
        $(this).toggleClass("list_item_check")
    })
</script>
<!-- 递归填充目录 单选  -->
<script>
    var department = "";
    $.ajax({
        type: 'get',
        url: "{:url('base/base_department_page')}",
        dataType:"json",
        async: false,
        success: function (data) {
            // eventList = JSON.parse(data);
            department = data;
        }
    })
    var an_tree = ergodic(department)
    $("#myModal_single .an_tree").append(an_tree);
    function ergodic(data) {
        var content = '';
        $.each(data, function (index, value) {
            if (value.children != "") {
                var children = ergodic(value.children);
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"><i class="fa fa-caret-right"></i></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.title + '</span></div></div><div class="an_tree_pack">' + children + '</div></div>';
            } else {
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.title + '</span></div></div><div class="an_tree_pack"></div></div>';
            }
        });
        return content;
    }
</script>


<!-- 拟稿提交按钮触发弹窗 -->
<script>
    $(".audit_sub_submit,.ch_sub_submit").click(function () {
        var item = $(this);
        var className = item.attr("class");
        var form = item.parents(".form-horizontal");
        var fuser_id = form.attr('data-fuser');
        var ruser_id = form.attr('data-ruser');
        var luser_id = form.attr('data-luser');
        var status = form.attr('data-status');
        var user_id = "{$user_id}";
        if((status == 1 && fuser_id == user_id)||(status == 2 && luser_id == user_id)||(status == 4 && fuser_id != user_id)||(status == 0 && ruser_id == user_id)){
            item.parents(".form-horizontal").find(".submits").click();
            return false;
        }
        $('#myModal2').modal('show');
        $("#tips_submit").click(function () {
            var check_opinion = $("#check_opinion_textarea").val();
            item.parents(".form-horizontal").find(".check_opinion").val(check_opinion);
            item.parents(".form-horizontal").find(".submits").click();
            $('#myModal2').modal('hide');
        });
        return false;
    });
</script>
<!-- 拟稿提交按钮触发弹窗DOM结构 -->
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2">
    <div class="modal-dialog" role="document">
        <div class="modal-content move">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel2">提示</h4>
            </div>
            <div class="modal_body" style="width: 100%;padding: 20px;">
                <label style="width: 100%;margin: 0!important;">
                    请填写您的初审意见：
                    <textarea name="check_opinion_textarea" id="check_opinion_textarea" cols="45" rows="5"
                        style="display: block;width: 100%;max-height: 100px; margin:0;padding: 10px;border-radius: 5px;"
                        placeholder="可以输入一千字"></textarea>
                </label>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="tips_submit">确认</button>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['layer', 'laydate', 'upload'], function(){
        var laydate = layui.laydate;
        var layer = layui.layer;
        var upload = layui.upload;
        var layer_index = '';//加载层
        laydate.render({
            range:true,
            elem: '.lay_date',
        });
        upload.render({
            elem: '#import'
            ,url: "{:url('review_import')}",
            accept:"file",
            exts:'xlsx',
            size:'8192', // 8M大小
            choose:function(obj){
                layer_index = layer.load(2);
            },
            done: function(res){
                layer.close(layer_index);
                if(res.err == 1){
                    // layer.msg(res.msg, {icon:2});
                    layer.open({
                        type: 1,
                        title:'错误信息',
                        skin: 'layui-layer-demo', //样式类名
                        closeBtn: 1, //不显示关闭按钮
                        anim: 2,
                        shadeClose: true, //开启遮罩关闭
                        content: res.msg
                    });
                }else{
                    layer.msg(res.msg, {icon:1}, function(){
                        location.reload();
                    });
                }
            },
            error: function(){
                layer.close(layer_index);
            }
        });
    });
    $('#sort').on('click',function () {
        if(show){
            var url = "{:url('by_condition')}"+'?'+$('#form2').serialize();
        }else{
            var url = "{:url('by_condition')}"+'?'+$('#form1').serialize();
        }
        window.location.href = url;
    })
    $('#import_a').on('click',function () {
        if(show){
            var url = "{:url('daily_export')}"+'?'+$('#form2').serialize();
        }else{
            var url = "{:url('daily_export')}"+'?'+$('#form1').serialize();
        }
        $.amaran({'message':'正在导出,请等待...'});
        window.location.href = url;
    })
</script>
{/block}